package com.demo.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.demo.entity.User;
import com.demo.service.IUserService;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import java.sql.SQLException;
import java.sql.Wrapper;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author canger123
 * @since 2019-02-26
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private IUserService userService;


    //分页插件
    @RequestMapping("/getPage")
    @ResponseBody
    public List<User> getPage(){
        Page<User> page = new Page<>(2,5);
//        Page<User> page = new Page<>();
         page = userService.selectPage(page);

//        userService.selectList();
        List<User> users = page.getRecords();
        System.out.println(users);
        System.out.println(page);
        System.out.println("总条数 ------> " + page.getTotal());
        System.out.println("当前页数 ------> " + page.getCurrent());
        System.out.println("当前每页显示数 ------> " + page.getSize());
        System.out.println("总页数 ------> " + page.getPages());
        return users;
    }

}

